﻿using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace JustTypeUI
{
    /// <summary>
    /// Task that contains tasks infomations
    /// 
    /// Main Author: Han Yu, Meng Kaizhi
    /// </summary>
    public class Task : INotifyPropertyChanged
    {
        protected string name;
        protected string location;
        protected DateTime deadline;
        protected int index;
        protected int status;
        protected List<string> key;

        public string Name
        {
            get { return name; }
            set 
            { 
                name = value; 
                OnPropertyChanged("Name");
            }
        }

        public string Location
        {
            get { return location; }
            set { location = value; }
        }

        public DateTime Deadline
        {
            get { return deadline; }
            set { deadline = value; }
        }

        public int Index
        {
            get { return index; }
            set { index = value; }
        }

        public List<string> Key
        {
            get { return key; }
            set { key = value; }
        }

        public int Status
        {
            get { return status; } 
            set { status = value; }
        }

        public String getStatusString()
        {
            String result = "";
            switch (status)
            {
                case 0:
                    result = ("Scheduled");
                    break;
                case 1:
                    result = ("Done");
                    break;
                case 2:
                    result = ("Coming Soon");
                    break;
                case 3:
                    result = ("OVERDUE");
                    break;
                default:
                    result = "Unknown";
                    break;
            }
            return result;
        }

        public Task Copy()
        {
            Task copy = new Task();
            copy.Name = this.Name;
            copy.Location = this.Location;
            copy.Deadline = this.Deadline;
            copy.Status = this.Status;
            return copy;
        }

          #region INotifyPropertyChanged Members
 
         public event PropertyChangedEventHandler PropertyChanged;
 
         protected void OnPropertyChanged(string name)
         {
             PropertyChangedEventHandler handler = PropertyChanged;
             if (handler != null)
             {
                 handler(this, new PropertyChangedEventArgs(name));
             }
         }
 
         #endregion
    }
}
